function showHint1(str)
{
	if (str.length==0)
	{
		document.getElementById("hint1").innerHTML="<font color='red'>用户名不能为空!</font>";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	       document.getElementById("hint1").innerHTML=xmlhttp.responseText;
	    }
	}
	xmlhttp.open("GET","checkreg.jsp?mes="+encodeURI(encodeURI(str)),true);
	xmlhttp.send();
}

function showHint4()
{//判断email格式
	var p = document.getElementById('email').value.trim();
	var e  =/^(.+)@(.+)\.(.+)$/;
	if(p.match(e))
	{

		document.getElementById('hint4').innerHTML = "Yes";
	}
	else
	{
		document.getElementById('hint4').innerHTML = "<font color='red'>邮箱格式不正确!</font>";
	}
}

function showHint2()
{//判断两次密码输入是否相同
	var p1 = document.getElementById('psw1').value.trim();
	var p2 = document.getElementById('psw2').value.trim();
	if(p1==p2)
	{
		if(p1.length<6)
		{
			document.getElementById('hint2').innerHTML = "<font color='red'>密码长度不能小于6!</font>";
			return;
		}
		document.getElementById('hint2').innerHTML = "Yes";
	}
	else
	{
		document.getElementById('hint2').innerHTML = "<font color='red'>两次密码不一致!</font>";
	}
}

function checkpass()
{
	var p2 = document.getElementById('psw2').value.trim();
	if(p2=="")
	{
		return;
	}
	var p1 = document.getElementById('psw1').value.trim();
	if(p1==p2)
	{
		if(p1.length<6)
		{
			document.getElementById('hint2').innerHTML = "<font color='red'>密码长度不能小于6!</font>";
			return;
		}
		document.getElementById('hint2').innerHTML = "Yes";
	}
	else
	{
		document.getElementById('hint2').innerHTML = "<font color='red'>两次密码不一致!</font>";
	}
}
function showyes()
{
	document.getElementById('hint3').innerHTML = "Yes";
}
function checkReg()
{
	var p1 = document.getElementById('hint1').innerHTML;
	var p2 = document.getElementById('hint2').innerHTML;
	var p3 = document.getElementById('hint3').innerHTML;
	var p4 = document.getElementById('hint4').innerHTML;
	var OK="Yes";
	if(p1.length<4 || p1.substr(1,3)!=OK)
	{
		alert('用户名不正确!');
		return false;
	}
	if(p2!=OK)
	{
		alert('密码不正确!');
		return false;
	}
	if(p3!=OK)
	{
		alert('请选择性别!');
		return false;
	}
	if(p4!=OK)
	{
		alert('邮箱不正确!');
		return false;
	}
	return true;
}
